#include "string_utils.h"

void StringUtils::Show(uint64_t *vals, long size)
{
    cout << "[";
    for (long i = 0; i < size; i++) {
        cout << vals[i] << ", ";
    }
    cout << "]" << endl;
}

void StringUtils::Show(long *vals, long size)
{
    cout << "[";
    for (long i = 0; i < size; i++) {
        cout << vals[i] << ", ";
    }
    cout << "]" << endl;
}

void StringUtils::Show(double *vals, long size)
{
    cout << "[";
    for (long i = 0; i < size; i++) {
        cout << vals[i] << ", ";
    }
    cout << "]" << endl;
}

void StringUtils::Show(complex<double> *vals, long size)
{
    cout << "[";
    for (long i = 0; i < size; i++) {
        cout << vals[i] << ", ";
    }
    cout << "]" << endl;
}

void StringUtils::ShowCompare(double val1, double val2, string prefix)
{
    cout << "---------------------" << endl;
    cout << "m" + prefix + ":" << val1 << endl;
    cout << "d" + prefix + ":" << val2 << endl;
    cout << "e" + prefix + ":" << val1 - val2 << endl;
    cout << "---------------------" << endl;
}

void StringUtils::ShowCompare(complex<double> val1, complex<double> val2, string prefix)
{
    cout << "---------------------" << endl;
    cout << "m" + prefix + ":" << val1 << endl;
    cout << "d" + prefix + ":" << val2 << endl;
    cout << "e" + prefix + ":" << val1 - val2 << endl;
    cout << "---------------------" << endl;
}

void StringUtils::ShowCompare(double *vals1, double *vals2, long size, string prefix)
{
    for (long i = 0; i < size; i++) {
        cout << "---------------------" << endl;
        cout << "m" + prefix + ": " << i << " :" << vals1[i] << endl;
        cout << "d" + prefix + ": " << i << " :" << vals2[i] << endl;
        cout << "e" + prefix + ": " << i << " :" << (vals1[i] - vals2[i]) << endl;
        cout << "---------------------" << endl;
    }
}

void StringUtils::ShowCompare(complex<double> *vals1, complex<double> *vals2, long size, string prefix)
{
    for (long i = 0; i < size; i++) {
        cout << "---------------------" << endl;
        cout << "m_" + prefix + ": " << i << " :" << vals1[i] << endl;
        cout << "d_" + prefix + ": " << i << " :" << vals2[i] << endl;
        cout << "err_" + prefix + ": " << i << " :" << (vals1[i] - vals2[i]) << endl;
        cout << "---------------------" << endl;
    }
}

complex<double> StringUtils::ShowCompare1(complex<double> *vals1, complex<double> *vals2, long size, int j)
{
    complex<double> maxError = vals1[0] - vals2[0];

    for (long i = 1; i < size; i++) {
        complex<double> error = vals1[i] - vals2[i];
        if (abs(error.real()) > abs(maxError.real())) {
            maxError.real(error.real());
        }
        if (abs(error.imag()) > abs(maxError.imag())) {
            maxError.imag(error.imag());
        }
    }
    cout << "左旋索引：" << j << "，最大误差:" << maxError << endl;
    // cout << "最大误差：" << i<<":"<<maxError << endl;
    return maxError;
}


void StringUtils::ShowCompare(double *vals1, double val2, long size, string prefix)
{
    for (long i = 0; i < size; i++) {
        cout << "---------------------" << endl;
        cout << "m" + prefix + ": " << i << " :" << vals1[i] << endl;
        cout << "d" + prefix + ": " << i << " :" << val2 << endl;
        cout << "e" + prefix + ": " << i << " :" << vals1[i] - val2 << endl;
        cout << "---------------------" << endl;
    }
}

void StringUtils::ShowCompare(complex<double> *vals1, complex<double> val2, long size, string prefix)
{
    for (long i = 0; i < size; i++) {
        cout << "---------------------" << endl;
        cout << "m" + prefix + ": " << i << " :" << vals1[i] << endl;
        cout << "d" + prefix + ": " << i << " :" << val2 << endl;
        cout << "e" + prefix + ": " << i << " :" << vals1[i] - val2 << endl;
        cout << "---------------------" << endl;
    }
}

void StringUtils::ShowCompare(double val1, double *vals2, long size, string prefix)
{
    for (long i = 0; i < size; i++) {
        cout << "---------------------" << endl;
        cout << "m" + prefix + ": " << i << " :" << val1 << endl;
        cout << "d" + prefix + ": " << i << " :" << vals2[i] << endl;
        cout << "e" + prefix + ": " << i << " :" << val1 - vals2[i] << endl;
        cout << "---------------------" << endl;
    }
}

void StringUtils::ShowCompare(complex<double> val1, complex<double> *vals2, long size, string prefix)
{
    for (long i = 0; i < size; i++) {
        cout << "---------------------" << endl;
        cout << "m" + prefix + ": " << i << " :" << val1 << endl;
        cout << "d" + prefix + ": " << i << " :" << vals2[i] << endl;
        cout << "e" + prefix + ": " << i << " :" << val1 - vals2[i] << endl;
        cout << "---------------------" << endl;
    }
}
